package com.zhentao.controller;

import com.zhentao.model.common.app.pojo.AppUser;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.app.dto.UserLoginDto;
import com.zhentao.service.AppUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
@Api(tags = "登录注册")
public class UserLoginController {

    @Autowired
    private AppUserService appUserService;

    @PostMapping("in")
    @ApiOperation("登录")
    public ResponseResult userLogin(@RequestBody UserLoginDto dto){
        System.out.println(dto);
        return appUserService.userLogin(dto);
    }

    @PostMapping("register")
    @ApiOperation("注册")
    public ResponseResult register(@RequestBody UserLoginDto dto){
        return appUserService.register(dto);
    }


    @PostMapping("/list")
    public ResponseResult userList(){
        ResponseResult result = appUserService.userList();
        return result;
    }

    /**
     * 用户信息完善
     * @param user
     * @return
     */
    @PostMapping("userInfo")
    public ResponseResult userInfo(@RequestBody AppUser user){
        return appUserService.userInfo(user);
    }


}
